﻿#ifndef WIDGET_H
#define WIDGET_H

#include "commandexecutor.h"
#include "csearchlineedit.h"
#include "customlistview.h"
#include "customsortfilterproxymodel.h"
#include "customtableview.h"


#include <QKeyEvent>
#include <QLabel>
#include <QStandardItem>
#include <QVBoxLayout>
#include <QWidget>
#include <QDateTime>
#include <QProcess>
#include <QSystemTrayIcon>


QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    CustomListView* createListView();
    CustomListView* createListView2();
    CustomListView* createListView3();
    void connectSignalsSlots();
    QStandardItemModel *createItemModel();
    CustomListView* createListViewByDelegate();
    CustomTableView *createTableView(QStandardItemModel *model);
    QString getTableViewSelectedRow();
    void wrongMessage();
    void rightMessage();
    void afterProcFinished(int exitCode, QProcess::ExitStatus exitStatus);
    void afterProcStarted();
    void initExecCmd();
    void sysTrayInit();
    void SysTrayActivated(QSystemTrayIcon::ActivationReason reason);
    QStringList readShortCutList(QString iniFilePath);
    void initHotkey(const QString hotkeyStr);
    CustomListView *createListView4();
private:
    Ui::Widget *ui;
    QLabel *label;
    CustomListView *listView;
    QStringList initTextList;
    CSearchLineEdit* pEdit;
    CustomTableView *tableView;
    QStandardItemModel *itemModel;
    QVBoxLayout* pVLay;
    CustomSortFilterProxyModel *proxyModel;
    CustomSortFilterProxyModel *proxyModelForListView;
    QProcess *proc;
    CommandExecutor *executor;
    QSystemTrayIcon *m_systray;
    QStringListModel *listShowModel;

private slots:
    void handleSearch(const QString& text);
    void handleSearch2(int value,const QString &key,const QString &text);
    void OnTextChanged(const QString& text);
    void onTabPressed(); // 槽函数，用于处理Tab键按下的事件
    void onListViewKeyPressed(QString* text);

    void initUI();
    void initUIListView();
    void initUITableView();
protected:
    void keyPressEvent(QKeyEvent *event) override;

signals:
    void tabPressed(); // 自定义信号，用于触发其他槽函数
    void itemMoved(int value,QString key,QString text);//按tab时发送该信号
    void itemMovedPrev(int value,QString key,QString text);//按shift+tab时发送该信号
    void sig_input(QString* text);//按tab时发送该信号
};


#endif // WIDGET_H
